
package sceneInfo;

/**
 *	This class holds visual information about player
 * 
 */
public class PlayerInfo extends ObjectInfo
{

	private static final long serialVersionUID = 1L;

	//default values
	String  m_teamName = "";
	int m_uniformNumber = 0;        // recognise 0 as not being able to see number
	float m_bodyDir = 0;
	float m_headDir = 0;
	boolean m_goalie = false;

	/** Default constructor, sets the team name to "", the uniform number to 0, 
	 * the body director to 0, the head direction to 0, and sets the player to
	 * not be a goalie
	 * 
	 */
	public PlayerInfo()
	{
		super("player");
	}
	
	/**get a string representation of this player
	 * 
	 */
	public String toString(){
		return "[Player (unif:"+m_uniformNumber+"/"+" team:"+m_teamName+") at "+getDistance()+"m / dir="+getDirection()+"]"; 
	}

	/** Similar to the default constructor, except the team name, uniform
	 * number, and whether the player is a goalie can be specified.
	 * 
	 * @param team The team name
	 * @param number The player uniform number
	 * @param is_goalie true if the player is a goalie, false otherwise
	 */
	public PlayerInfo(String team, int number, boolean is_goalie)
	{
		super("player");
		setTeamName(team);
		m_uniformNumber = number;
		m_goalie = is_goalie;
		m_bodyDir = 0;
		m_headDir = 0;
	}

	/** Similar to the default constructor, except the team name, uniform
	 * number,body direction and head direction can be specified
	 * 
	 * @param team Team name
	 * @param number Uniform Number
	 * @param bodyDir Body Direction
	 * @param headDir Head Direction
	 */
	public PlayerInfo(String team, int number, float bodyDir, float headDir)
	{
		super("player");
		setTeamName(team);
		m_uniformNumber = number;
		m_bodyDir = bodyDir;
		m_headDir = headDir;
	}

	/** Set the team name
	 *  
	 * @param team Team name
	 */
	public void setTeamName(String team)
  	{
		//the following code will strip any quotes off the team name
		if (team.compareTo("") == 0) {
			m_teamName = team;
		}
		else if (team.charAt(0) == '"' && team.charAt(team.length()-1) == '"') {
			m_teamName = team.substring(1, team.length() - 1);
		}
		else {
			m_teamName = team;
		}
  	}

	/** Get the team name
	 * 
	 */
	public String getTeamName()
	{
    	return m_teamName;
	}

	/** Set if the player is a goalie
	 * 
	 * @param goalie true if the player is a goalie
	 */
	public void setGoalie(boolean goalie)
	{
		m_goalie = goalie;
	}

	/** Check if the player is a goalie
	 * 
	 * @return true if the player is a goalie
	 */
  	public boolean isGoalie()
  	{
  		return m_goalie;
  	}

  	public void setUniformNumber(int uniNum){
  		m_uniformNumber = uniNum;
  	}
  	
  	public int getUniformNumber()
  	{
  		return m_uniformNumber;
  	}

	public float getBodyDir() {
		return m_bodyDir;
	}

	public void setBodyDir(float dir) {
		m_bodyDir = dir;
	}

	public float getHeadDir() {
		return m_headDir;
	}

	public void setHeadDir(float dir) {
		m_headDir = dir;
	}
}

